package com.zj.fx.service.info;

import java.util.List;
import java.util.Arrays;

import com.zj.fx.mapper.info.InfoFileMapper;
import com.zj.fx.model.info.InfoFile;
import com.zj.fx.model.info.InfoFileExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import cn.hutool.core.util.StrUtil;
import com.zj.fx.common.base.BaseService;
import com.zj.fx.common.support.ConvertUtil;
import com.zj.fx.model.custom.Tablepar;
import com.zj.fx.util.SnowflakeIdWorker;
import com.zj.fx.util.StringUtils;

/**
 * 业务附件表 InfoFileService
 *
 * @author SQL_自动生成
 * @Title: InfoFileService.java 
 * @Package com.zj.fx.service 
 * @email ${email}
 * @date 2023-06-06 23:07:07  
 **/
@Service
public class InfoFileService implements BaseService<InfoFile, InfoFileExample> {
    @Autowired
    private InfoFileMapper infoFileMapper;


    /**
     * 分页查询
     *
     * @param
     * @param
     * @return
     */
    public PageInfo<InfoFile> list(Tablepar tablepar, InfoFile infoFile) {
        InfoFileExample testExample = new InfoFileExample();
        //搜索
        if (StrUtil.isNotEmpty(tablepar.getSearchText())) {//小窗体
            testExample.createCriteria().andLikeQuery2(tablepar.getSearchText());
        } else {//大搜索
            testExample.createCriteria().andLikeQuery(infoFile);
        }
        //表格排序
        //if(StrUtil.isNotEmpty(tablepar.getOrderByColumn())) {
        //	testExample.setOrderByClause(StringUtils.toUnderScoreCase(tablepar.getOrderByColumn()) +" "+tablepar.getIsAsc());
        //}else{
        //	testExample.setOrderByClause("id ASC");
        //}
        PageHelper.startPage(tablepar.getPage(), tablepar.getLimit());
        List<InfoFile> list = infoFileMapper.selectByExample(testExample);
        PageInfo<InfoFile> pageInfo = new PageInfo<InfoFile>(list);
        return pageInfo;
    }

    @Override
    public int deleteByPrimaryKey(String ids) {

        List<String> lista = ConvertUtil.toListStrArray(ids);
        InfoFileExample example = new InfoFileExample();
        example.createCriteria().andIdIn(lista);
        return infoFileMapper.deleteByExample(example);

    }


    @Override
    public InfoFile selectByPrimaryKey(String id) {
        return infoFileMapper.selectByPrimaryKey(id);

    }


    @Override
    public int updateByPrimaryKeySelective(InfoFile record) {
        return infoFileMapper.updateByPrimaryKeySelective(record);
    }


    /**
     * 添加
     */
    @Override
    public int insertSelective(InfoFile record) {
        return infoFileMapper.insertSelective(record);
    }


    @Override
    public int updateByExampleSelective(InfoFile record, InfoFileExample example) {

        return infoFileMapper.updateByExampleSelective(record, example);
    }


    @Override
    public int updateByExample(InfoFile record, InfoFileExample example) {

        return infoFileMapper.updateByExample(record, example);
    }

    @Override
    public List<InfoFile> selectByExample(InfoFileExample example) {

        return infoFileMapper.selectByExample(example);
    }


    @Override
    public long countByExample(InfoFileExample example) {

        return infoFileMapper.countByExample(example);
    }


    @Override
    public int deleteByExample(InfoFileExample example) {

        return infoFileMapper.deleteByExample(example);
    }

    public int deleteById(String id) {
        return infoFileMapper.deleteById(id);
    }

}
